package com.ruoyi.erp.safetyinstruction.service.impl;

import com.ruoyi.erp.safetyinstruction.domain.SafetyInstructionTab;
import com.ruoyi.erp.safetyinstruction.mapper.SafetyInstructionMapper;
import com.ruoyi.erp.safetyinstruction.service.SafetyInstructionService;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * @version 2017.1.1
 * @Auther Du Ruifang @萌えキュンキュン
 * @Date 2020/12/25 10:10
 * @description 该类的作用
 */
@Service
public class SafetyInstructionServiceImpl implements SafetyInstructionService {
    @Autowired
    private SafetyInstructionMapper safetyInstructionMapper;

    @Override
    public List<SafetyInstructionTab> getList(SafetyInstructionTab safetyInstructionTab) {
        return safetyInstructionMapper.getList(safetyInstructionTab);
    }

    @Override
    public void saveSafetyInstruction(SafetyInstructionTab safetyInstructionTab) {
        safetyInstructionTab.setRowversion(new Date());
        String s = UUID.randomUUID().toString().replace("-", "").toUpperCase();
        String s1 = RandomStringUtils.randomNumeric(10);
        safetyInstructionTab.setRowkey(s+""+s1);
        safetyInstructionMapper.saveSafetyInstruction(safetyInstructionTab);
    }

    @Override
    public SafetyInstructionTab findSafetyInstruction(String hazardCode) {
        return safetyInstructionMapper.findSafetyInstruction(hazardCode);
    }

    @Override
    public void editSaveSafetyInstruction(SafetyInstructionTab safetyInstructionTab) {
        safetyInstructionMapper.editSaveSafetyInstruction(safetyInstructionTab);
    }

    @Override
    public int deleteSafetyInstruction(String[] ids) {
        return safetyInstructionMapper.deleteSafetyInstruction(ids);
    }

    @Override
    public SafetyInstructionTab getInfoByHazardCode(String hazardCode) {
        return safetyInstructionMapper.getInfoByHazardCode(hazardCode);
    }
}
